home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / program / 441 / dlibs12 / fwrite.c < prev    next >
C/C++ Source or Header  |  1990-11-23  |  590b  |  30 lines

  1. #include <osbind.h>
  2. #include <stdio.h>
  3. #include <errno.h>
  4.  
  5. int fwrite(data, size, count, fp)
  6.     register char *data;
  7.     int size;
  8.     int count;
  9.     register FILE *fp;
  10.     {
  11.     register long n, m, lsiz;
  12.     register int f, c;
  13.  
  14.     f = (fp->_flag |= _IORW);
  15.     lsiz = ((long) size);
  16.     n = ((long) count) * lsiz;
  17.     if(f & _IODEV)            /* device i/o */
  18.         {
  19.         for(m=0; m<n; ++m)
  20.             if(fputc(*data++, fp) == EOF)
  21.                 break;
  22.         }
  23.     else                /* file i/o */
  24.         {
  25.         fflush(fp);            /* re-sync file pointers */
  26.         m = Fwrite(fp->_file, n, data);
  27.         }
  28.     return((m > 0) ? (m / lsiz) : (errno = ((int) m)));
  29.     }
  30.